//
//  FileCleanM.swift
//  ZJTools
//
//  Created by 万孟超 on 2023/10/19.
//

import Foundation

class FileCleanResult {
    var floderList: [FileCleanM]
    
    var path: String
    
    init(path: String, floderList: [FileCleanM]) {
        self.path = path
        self.floderList = floderList
    }
    
    subscript (name: String) -> FileCleanM {
        for floderModel in floderList {
            if !floderModel.isFile && floderModel.name == name {
                return floderModel
            }
        }
        let floder = FileCleanM(isFile: false, name: name, fullPath: path + "/" + name, subFloderList: [])
        floderList.append(floder)
        return floder
    }
}

class FileCleanM {
    var isFile: Bool
    
    var name: String
    
    var fullPath: String
    
    var subFloderList: [FileCleanM] = []
    
    init(isFile: Bool, name: String, fullPath: String = "", subFloderList: [FileCleanM] = []) {
        self.isFile = isFile
        self.name = name
        self.fullPath = fullPath
        self.subFloderList = subFloderList
    }
    
    subscript (subName: String) -> FileCleanM {
        for subFloder in subFloderList {
            if !subFloder.isFile && subFloder.name == subName {
                return subFloder
            }
        }
        let floder = FileCleanM(isFile: false, name: subName, fullPath: fullPath + "/" + subName, subFloderList: [])
        subFloderList.append(floder)
        return floder
    }
}
